[RTL8722CSM] [RTL8722DM] GPIO - 闪烁LED
材料准备
Ameba x 1
LED x 1
电阻(阻值200奥姆)x 1
范例说明
闪烁LED是开始了解并使用MicroPython最好示例。
首先,如下图所示将PB_22引脚连接到与限流电阻串联的LED的阳极引脚,再将GND连接到LED的阴极引脚:
Then, copy the following code and press Ctrl + e in REPL to enter the paste mode (for more information about REPL and paste mode, check “Getting Started” page). If you are using Tera Term, simply right click on any blank space of the terminal and paste the code into REPL, then press Ctrl + d to execute the code. If everything is order, you should be able to see the LED blink for 3 times in 3 seconds.
from machine import Pin
a = Pin("PB_22", Pin.OUT)
a.value(1)
time.sleep_ms(500)
a.value(0)
time.sleep_ms(500)
a.on()
time.sleep_ms(500)
a.off()
time.sleep_ms(500)
a.toggle()
time.sleep_ms(500)
a.toggle()
